package test;

import com.alibaba.excel.EasyExcel;
import crawler01.ExcelClass;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author raok
 * @create 2022-04-25-21:10
 **/

public class CrawlerTest02 {

    public static void writeToExcel(String str) throws IOException {
        String[] strings = str.split("\\|");
        ArrayList<ExcelClass> list = new ArrayList<>(); //list的一个元素就是一行
        for (int i = 0; i < 3; i++) {
            ExcelClass excelClass = new ExcelClass();
            excelClass.setIndex(i);
            excelClass.setHref("href");
//            entity1.location="location";
//            entity1.price="price";
//            entity1.sendtime="sendtime";
//            entity1.title="title";
//            entity1.time="time";
            list.add(excelClass);
            System.out.println(list);
        }
        EasyExcel.write("easyexcel-user1.xlsx", CrawlerTest02.class).sheet("用户信息").doWrite(list);
    }

    public static void main(String[] args) throws IOException {
        writeToExcel("1|2");

    }
    @Test
    public void test() throws Exception {
        writeToExcel("1");

    }
}
